unit tests;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Buttons,
  ComCtrls;

type

  { TfrmTests }

  TfrmTests = class(TForm)
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    ProgressBar: TProgressBar;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  frmTests: TfrmTests;

implementation

{$R *.lfm}

{ TfrmTests }
uses main;

procedure TfrmTests.BitBtn1Click(Sender: TObject);
var
  i:Integer;
begin
  ProgressBar.Position:=0;
  ProgressBar.Max:=2789;
  for i:=0 to ProgressBar.Max do begin
    ProgressBar.Position:=i;
    FrmMain.DSNomenclature.DataSet.Append;
    FrmMain.DSNomenclature.DataSet.FieldByName('isgroup').AsBoolean:=False;
    FrmMain.DSNomenclature.DataSet.FieldByName('parentid').AsInteger:=0;
    randomize();                             //
    FrmMain.DSNomenclature.DataSet.FieldByName('title').AsString:='Якась назва товару new - '+IntToStr(random(99999)+23);
    randomize();
    FrmMain.DSNomenclature.DataSet.FieldByName('articleofgoods').AsString:='ARTOUT-'+IntToStr(random(5000)+3);
    randomize();
    FrmMain.DSNomenclature.DataSet.FieldByName('articleinside').AsString:='ARTIN-'+IntToStr(random(5000)+12);
    randomize();
    FrmMain.DSNomenclature.DataSet.FieldByName('quantity').AsInteger:=random(241)+2;
    randomize();
    FrmMain.DSNomenclature.DataSet.FieldByName('quantitymin').AsInteger:=random(100);
    randomize();
    FrmMain.DSNomenclature.DataSet.FieldByName('price').AsInteger:=random(2678);
    randomize();
    FrmMain.DSNomenclature.DataSet.FieldByName('priceretail').AsInteger:=random(10)+50;
    randomize();
    FrmMain.DSNomenclature.DataSet.FieldByName('pricesmallwholesale').AsInteger:=random(15)+30;
    randomize();
    FrmMain.DSNomenclature.DataSet.FieldByName('pricebigwholesale').AsInteger:=random(10)+20;
    FrmMain.DSNomenclature.DataSet.Post;
  end;
  ShowMessage('Done');
end;

procedure TfrmTests.BitBtn2Click(Sender: TObject);
var
  i:Integer;
begin
  ProgressBar.Position:=0;
  ProgressBar.Max:=569;
  for i:=0 to ProgressBar.Max do begin
    ProgressBar.Position:=i;
    FrmMain.DSCounterParties.DataSet.Append;
    FrmMain.DSCounterParties.DataSet.FieldByName('isgroup').AsBoolean:=False;
    FrmMain.DSCounterParties.DataSet.FieldByName('parentid').AsInteger:=1;
    randomize();                             //
    FrmMain.DSCounterParties.DataSet.FieldByName('title').AsString:='Якась назва товару new - '+IntToStr(random(99999)+23);
    randomize();                             //
    FrmMain.DSCounterParties.DataSet.FieldByName('info').AsString:='Якась Info - '+IntToStr(random(9999)+23);
    FrmMain.DSCounterParties.DataSet.Post;
  end;
  ShowMessage('Done');
end;

end.

